<html>
<head><meta charset="utf-8"><title>const prop into operands · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html">const prop into operands</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204339934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204339934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204339934">(Jul 19 2020 at 08:58)</a>:</h4>
<p>propagating into operands is an independent thing of the cross basic-block optimization, if someone wants to implement that for more things than call terminators, I'd be happy to mentor</p>



<a name="204340338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204340338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204340338">(Jul 19 2020 at 09:10)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span>  wanna give me some pointers, this seems interesting</p>



<a name="204341046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204341046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204341046">(Jul 19 2020 at 09:31)</a>:</h4>
<p>Basically we have this very specific optimization for const propping into the operands in function arguments: <a href="https://github.com/rust-lang/rust/blob/0701419e96d94e5493c7ebfcecb66511ab0aa778/src/librustc_mir/transform/const_prop.rs#L1102">https://github.com/rust-lang/rust/blob/0701419e96d94e5493c7ebfcecb66511ab0aa778/src/librustc_mir/transform/const_prop.rs#L1102</a></p>



<a name="204341121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204341121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204341121">(Jul 19 2020 at 09:32)</a>:</h4>
<p>I think we can remove most of that and add a <code>visit_operand</code> method to the visitor that does the <code>Operand::Copy</code> or <code>Operand::Move</code> to <code>Operand::Const</code> conversion if the local is a  known constant</p>



<a name="204341529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204341529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204341529">(Jul 19 2020 at 09:45)</a>:</h4>
<p>Thanks <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="204342364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342364">(Jul 19 2020 at 10:10)</a>:</h4>
<p>Awesome! I was going to start this after doing Boolean identities but the more the merrier :)</p>



<a name="204342551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342551">(Jul 19 2020 at 10:17)</a>:</h4>
<blockquote>
<p>The following code would appear to be incomplete, because<br>
                          the function <code>Operand::place()</code> returns <code>None</code> if the<br>
<code>Operand</code> is of the variant <code>Operand::Constant</code>.</p>
</blockquote>



<a name="204342590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342590">(Jul 19 2020 at 10:18)</a>:</h4>
<p>what should be done for <code>Operand::Constant</code> here, afaict we go from <code>Operand::Copy|Move</code> to <code>Operand::Constant</code></p>



<a name="204342591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342591">(Jul 19 2020 at 10:18)</a>:</h4>
<p>so I don't see what we would do for constants if they appeared here</p>



<a name="204342598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342598">(Jul 19 2020 at 10:19)</a>:</h4>
<p>don't do anything for <code>Operand::Const</code></p>



<a name="204342599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342599">(Jul 19 2020 at 10:19)</a>:</h4>
<p>it's already constant ^^ nothing to propagate here</p>



<a name="204342600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342600">(Jul 19 2020 at 10:19)</a>:</h4>
<p>yeah, but I don't understand that comment rn</p>



<a name="204342604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342604">(Jul 19 2020 at 10:19)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/0701419e96d94e5493c7ebfcecb66511ab0aa778/src/librustc_mir/transform/const_prop.rs#L1108-L1111">https://github.com/rust-lang/rust/blob/0701419e96d94e5493c7ebfcecb66511ab0aa778/src/librustc_mir/transform/const_prop.rs#L1108-L1111</a></p>



<a name="204342605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342605">(Jul 19 2020 at 10:20)</a>:</h4>
<p>oh there's a comment? <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>



<a name="204342651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342651">(Jul 19 2020 at 10:20)</a>:</h4>
<p>I want to replace this with <code>for opr in args { self.visit_operand(opr, location) }</code></p>



<a name="204342657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342657">(Jul 19 2020 at 10:20)</a>:</h4>
<p>oooh</p>



<a name="204342707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342707">(Jul 19 2020 at 10:22)</a>:</h4>
<p>I think we should just have <code>walk_terminator</code> directly at the beginning of <code>visit_terminator</code></p>



<a name="204342711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342711">(Jul 19 2020 at 10:22)</a>:</h4>
<p>then you don't need any replacement code for the thing you linked</p>



<a name="204342720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342720">(Jul 19 2020 at 10:22)</a>:</h4>
<p>don't we already use <code>super_terminator</code> here?</p>



<a name="204342727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342727">(Jul 19 2020 at 10:23)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/0701419e96d94e5493c7ebfcecb66511ab0aa778/src/librustc_mir/transform/const_prop.rs#L999">https://github.com/rust-lang/rust/blob/0701419e96d94e5493c7ebfcecb66511ab0aa778/src/librustc_mir/transform/const_prop.rs#L999</a></p>



<a name="204342861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204342861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204342861">(Jul 19 2020 at 10:26)</a>:</h4>
<p>do all mir-opt-tests run with <code>mir-opt-level =2</code> by default?</p>



<a name="204343074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204343074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204343074">(Jul 19 2020 at 10:33)</a>:</h4>
<p>this felt slightly too easy so I might have missed something here: <a href="https://github.com/rust-lang/rust/issues/74507">#74507</a></p>



<a name="204343241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204343241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204343241">(Jul 19 2020 at 10:38)</a>:</h4>
<p>O_o</p>



<a name="204343253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204343253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204343253">(Jul 19 2020 at 10:39)</a>:</h4>
<p>I think you can remove the <code>TerminatorKind::SwitchInt</code> arm, too</p>



<a name="204343261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204343261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204343261">(Jul 19 2020 at 10:39)</a>:</h4>
<p>and the <code>else</code> arm in <code>Assert</code></p>



<a name="204343456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204343456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204343456">(Jul 19 2020 at 10:45)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="204353024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204353024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204353024">(Jul 19 2020 at 14:24)</a>:</h4>
<p>As a casual observer, I’d love for these things to be documented as expected to improve compile performance (eg reduced LLVM IR) improve runtime performance (eg reduced code in the final executable) or other. </p>
<p>But as a casual observer, I don’t want to make any demands 😇</p>



<a name="204364555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204364555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204364555">(Jul 19 2020 at 18:29)</a>:</h4>
<p>it doesn't look like this improves the compile time <a href="https://github.com/rust-lang/rust/pull/74507#issuecomment-660685419">https://github.com/rust-lang/rust/pull/74507#issuecomment-660685419</a></p>
<p><span class="user-mention" data-user-id="124288">@oli</span> do we want to restrict this to <code>mir-opt-level = 2</code>?</p>



<a name="204364695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204364695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204364695">(Jul 19 2020 at 18:33)</a>:</h4>
<p>I think we do</p>



<a name="204364750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204364750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204364750">(Jul 19 2020 at 18:34)</a>:</h4>
<p>This might be related to CGU partitioning, which has been a problem in the past (see: the propagation step into function arguments)</p>



<a name="204364754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204364754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204364754">(Jul 19 2020 at 18:34)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> do you think that's the case here as well?</p>



<a name="204364765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204364765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204364765">(Jul 19 2020 at 18:35)</a>:</h4>
<p>That this regresses because of the CGU partitioning scheme?</p>



<a name="204364982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204364982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204364982">(Jul 19 2020 at 18:40)</a>:</h4>
<p>I think per <a href="https://github.com/rust-lang/compiler-team/issues/319">https://github.com/rust-lang/compiler-team/issues/319</a> it needs to go under<code> mir-opt-level=3</code></p>



<a name="204365334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204365334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204365334">(Jul 19 2020 at 18:51)</a>:</h4>
<p>Oh, true!</p>



<a name="204365336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204365336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204365336">(Jul 19 2020 at 18:51)</a>:</h4>
<p>:)</p>



<a name="204367687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204367687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204367687">(Jul 19 2020 at 19:37)</a>:</h4>
<p>would it be worth investigating the regressions further?</p>



<a name="204367729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204367729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204367729">(Jul 19 2020 at 19:38)</a>:</h4>
<p>because doing this opt would unlock a lot of further opportunities for optimization</p>



<a name="204368025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204368025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204368025">(Jul 19 2020 at 19:46)</a>:</h4>
<p>looking at the worst test case it seems to spend 15s more in <code>LLVM_lto_optimize</code>, 5 more in <code>LLVM_thin_lto_import</code> and 8 more in <code>LLVM_module_codegen_emit_obj</code>, could it be that this transformation is too aggressive and blowing up the size of code that needs to be generated?</p>



<a name="204369143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204369143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204369143">(Jul 19 2020 at 20:17)</a>:</h4>
<p>there's been a design meeting on this CGU partitioning issue already, see <a href="#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bdesign.20meeting.5D.20codegen.20unit.20partitioning.20compiler-team.23281">this topic</a> (I don't remember what the plan is, maybe the incremental compilation wg will look at it)</p>



<a name="204370713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204370713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204370713">(Jul 19 2020 at 21:04)</a>:</h4>
<p><span class="user-mention" data-user-id="312719">@Xavier Denis</span> regarding the code generation: we seem to currently be at a local optimum, i.e. the code generation unit partitioning scheme for incremental compilation seems to be tuned in favor of how the compiler behaves today, and its performance gets easily broken by changes in how we generate code (e.g. with better MIR opts)</p>



<a name="204370730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204370730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204370730">(Jul 19 2020 at 21:05)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> was looking into it. If I remember correctly, they did a refactor of the current scheme to prepare it for future changes.</p>



<a name="204370778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204370778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204370778">(Jul 19 2020 at 21:06)</a>:</h4>
<p>Yeah, I think this is something the wg-incr-comp group wants to work on</p>



<a name="204370780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204370780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204370780">(Jul 19 2020 at 21:06)</a>:</h4>
<p>But, of course, anyone is welcome to dig in and look for solutions <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="204370782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204370782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204370782">(Jul 19 2020 at 21:06)</a>:</h4>
<p>They were also experimenting with generating a lot more CGUs, so that incremental compilation didn't have to re-do as much work as it is doing today for trivial changes like adding a println!</p>



<a name="204370800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204370800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204370800">(Jul 19 2020 at 21:07)</a>:</h4>
<p>Because big CGUs help for runtime performance, which we don't really care about in debug incremental compilation</p>



<a name="204370845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204370845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204370845">(Jul 19 2020 at 21:08)</a>:</h4>
<p>I would bet that at least half of the current "implemented but disabled" mir-opts regress just from the CGU partitioning scheme alone x3</p>



<a name="204371710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204371710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204371710">(Jul 19 2020 at 21:33)</a>:</h4>
<p>is there any way to debug CGU partitioning? ie: is it possible to see how the units are determined before &amp; after a change?</p>



<a name="204372951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204372951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204372951">(Jul 19 2020 at 22:10)</a>:</h4>
<p>No idea. That sounds like it could be super useful to debug the quality of the scheme, tho!</p>



<a name="204372962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204372962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204372962">(Jul 19 2020 at 22:11)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> please tell me if I'm pinging you too much, but I think you're like the only one in the team who's remotely familiar with the CGU partitioning step?</p>



<a name="204377388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204377388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204377388">(Jul 20 2020 at 00:30)</a>:</h4>
<p>It's fine :)</p>



<a name="204377399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204377399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204377399">(Jul 20 2020 at 00:31)</a>:</h4>
<p>I've been using <code>RUSTC_LOG=rustc_mir::monomorphize::partitioning {rustc or cargo invocation here}</code></p>



<a name="204377406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204377406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204377406">(Jul 20 2020 at 00:31)</a>:</h4>
<p>I believe there's also a <code>-Z</code> flag which dumps some data on this</p>



<a name="204401533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204401533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204401533">(Jul 20 2020 at 09:20)</a>:</h4>
<p>yes <code>-Z print-mono-items=lazy</code>(or say, "eager") :)</p>



<a name="204401610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204401610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204401610">(Jul 20 2020 at 09:21)</a>:</h4>
<p>(which I'm slowly working on, to try and make slightly more helpful for different use cases, like at least 1. seeing the gains of polymorphization AKA "david's use case", 2. seeing the advantages/drawbacks of our cgu partitioning scheme and process and diff that AKA "wesley/wg-incr's", 3. having more visibility into the amount/cost of monomorphizations and the likes AKA "niko/matklad's/everyone with long compile times")</p>



<a name="204415485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204415485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Xavier Denis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204415485">(Jul 20 2020 at 12:27)</a>:</h4>
<p>it'd be awesome to print the size estimates of different items so that we could compare the before and after of a change like this and see what actually changed</p>



<a name="204607014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204607014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204607014">(Jul 21 2020 at 21:51)</a>:</h4>
<p>restricted this to mir-opt-level=3. As we now have the same locations for all operand propagations, this also disables it for <code>SwitchInt</code> and <code>Assert</code>, which isn't great. Not sure how to deal with that without just closing this PR <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="204638326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638326">(Jul 22 2020 at 07:49)</a>:</h4>
<p>breaks an incremental test</p>



<a name="204638335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638335">(Jul 22 2020 at 07:49)</a>:</h4>
<p>yea, see also my comment on the PR <span aria-label="wink" class="emoji emoji-1f609" role="img" title="wink">:wink:</span></p>



<a name="204638395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638395">(Jul 22 2020 at 07:50)</a>:</h4>
<p>let's not regress things while blocking only the advanced things under mir-opt-level 3</p>



<a name="204638399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638399">(Jul 22 2020 at 07:50)</a>:</h4>
<p>i still want to know why this happens though, we probably remove the changed span due to the opt</p>



<a name="204638403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638403">(Jul 22 2020 at 07:50)</a>:</h4>
<p>which seems interesting</p>



<a name="204638431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638431">(Jul 22 2020 at 07:51)</a>:</h4>
<p>oh, you mean "breaks a test" as in turning off propagation makes it mark less stuff as dirty?</p>



<a name="204638437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638437">(Jul 22 2020 at 07:51)</a>:</h4>
<p>more stuff is dirty</p>



<a name="204638444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638444">(Jul 22 2020 at 07:51)</a>:</h4>
<p>if the optimization is not run at all</p>



<a name="204638528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638528">(Jul 22 2020 at 07:52)</a>:</h4>
<p>right, that makes sense</p>



<a name="204638531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638531">(Jul 22 2020 at 07:52)</a>:</h4>
<p>how can I emit the final mir in a test?</p>



<a name="204638539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638539">(Jul 22 2020 at 07:53)</a>:</h4>
<p>I want to see what exactly changes here</p>



<a name="204638542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638542">(Jul 22 2020 at 07:53)</a>:</h4>
<p>if we optimize away an <code>if false</code> in both cases, the contents of the branch don't matter</p>



<a name="204638565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638565">(Jul 22 2020 at 07:53)</a>:</h4>
<p>uh.... something something <code>-Z emir=mir</code>?</p>



<a name="204638571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638571">(Jul 22 2020 at 07:53)</a>:</h4>
<p>using<code>// EMIT_MIR rustc.try_identity.SimplifyLocals.after.mir</code></p>



<a name="204638572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/204638572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#204638572">(Jul 22 2020 at 07:53)</a>:</h4>
<p>I alway use <code>-Z dump-mir=all</code> and be done with it XD</p>



<a name="211004149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/211004149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#211004149">(Sep 23 2020 at 13:42)</a>:</h4>
<p>Has anyone checked if the compile time regression went away with LLVM 11?</p>



<a name="211005793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/211005793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#211005793">(Sep 23 2020 at 13:53)</a>:</h4>
<p>I don't think so. Feel free to open a PR trying out setting the mir-opt-level to 1 and ping me, I'll start a perf run</p>



<a name="211006752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/211006752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#211006752">(Sep 23 2020 at 13:59)</a>:</h4>
<p>Thanks! Hope I did it correctly. I cc'd you on GH but just in case, <a href="https://github.com/rust-lang/rust/issues/77107">#77107</a></p>



<a name="211029829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/const%20prop%20into%20operands/near/211029829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dániel Buga <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/const.20prop.20into.20operands.html#211029829">(Sep 23 2020 at 16:43)</a>:</h4>
<p>The results are in, and at least there's no 24% regression anywhere, but I don't know if it counts as good enough or not.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>